import xadmin
from xadmin import views
from .models import User


# 配置xadmin主题，注册的时候要用到专用的view去注册
class BaseSetting(object):
    enable_themes = True
    use_bootswatch = True


class GlobalSetting(object):
    site_title = '中学生兴趣课堂选课系统后台管理界面'    # 左上角标题名称
    site_footer = 'YangZai'                          # 底部公司名称
    menu_style = 'accordion'                         # 导航栏折叠


class UserXadmin(object):
    # 需要显示的字段
    list_display = ['css_name', 'css_id', 'css_gender', 'css_phone', 'css_time']
    # 搜索时可输入的字段内容
    search_fields = ['css_name']
    # 点击id可进入详细界面进行编辑（默认的）
    list_display_links = ('id',)
    # 可编辑的列名
    list_editable = ['css_id']
    # list_filter = ['css_url']
    # 每页显示多少条
    list_per_page = 1
    # 根据id排序
    ordering = ('id',)
    # 设置只读字段　
    readonly_fields = ('css_time',)
    # 显示本条数据的所有信息
    show_detail_fields = ['asset_name']
    # 图标
    model_icon = 'fa fa-picture-o'


# 注册主题类
xadmin.site.register(views.BaseAdminView, BaseSetting)
# 注册全局样式的类
xadmin.site.register(views.CommAdminView, GlobalSetting)
xadmin.site.register(User, UserXadmin)
